$(document).ready(function() {
	function send()
		{
			var email = $('#login input[name="email"]').attr("value");
			var password = $('#login input[name="password"]').attr("value");
			if (email=="" || password=="") $("#login_info").html("Please fill data ")
			else{
					$.ajax({
						  type	: "GET",
						  url	: "/login",
						  data: {
								email		:email,
								password	:password,
								}
						}).done(function( result ){
							console.dir( result );		
							if(result!=false)	window.location.href="/profile/"+result;
							else {
								//console.error("Invaild email or password");
								$("#login_info").html("Invaild Email or Password");
							}				
						});//sucsses or done
			};//else
		}
	$("#reg-button-in-login").click(function(){
			window.location.href="/registration";
	});
	$("#login-button").click(function(){
		send();
	});
	$('#login input[name="password"]').keypress(function (e){
		 if (e.which == 13) 
		 	{	 send();
		 		$("#login-button").css("color","red");		 
		 	}
	});
});